<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 2020-06-18
 * Time: 11:05
 * 项目孵化评论
 */

namespace app\api\controller\v1;

use app\api\model\ProjectHatch;
use app\api\service\project\CommentOrderSer;
use app\api\service\project\CommentSer;
use app\api\service\Token;
use think\facade\Request;

class ProjectComment
{
    // 判断评价权限
    public function judgeProjectComment($project_hatch_id)
    {
        $uid = Token::getCurrentUid();
        $projectHatch = ProjectHatch::get($project_hatch_id);
        if($projectHatch['user_id'] == $uid) {
            return [
                'isValid' => true
            ];
        } else {
            $info = Token::judgeProjectHatchComment();
            if($info) {
                return [
                    'isValid' => true
                ];
            } else {
                return [
                    'isValid' => false
                ];
            }
        }
    }

    // 创建订单
    public function createOrder($project_hatch_id)
    {
        $CommentOrderSer = new CommentOrderSer($project_hatch_id);
        return $CommentOrderSer->entrance();
    }

    // 创建评论
    public function createData()
    {
        $post = Request::post();
        $CommentSer = new CommentSer($post);
        return $CommentSer->entrance();
    }
}